<!--
 * @Description: 
 * @Author: xiongkuobiao
 * @Date: 2023-02-21 11:57:04
 * @LastEditors: xiongkuobiao
 * @LastEditTime: 2023-02-21 19:59:12
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    let arr = [1, [1, 2], 1, 2, [2, 3, 23, [22, 2, 222222222222]]];
    function flat(arr, newArr = []) {
      arr.forEach((item) => {
        if (Array.isArray(item)) {
          flat(item, newArr);
        } else {
          newArr.push(item);
        }
      });
      return newArr;
    }
    console.log(flat(arr));
  </script>
</html>
